import 'dart:math';

import 'package:flutter/material.dart';
import 'package:ceo_app/page/home/index.dart';
import 'package:ceo_app/page/login/index.dart';
import 'package:ceo_app/page/publish/index.dart';
import 'package:ceo_app/page/circle/index.dart';
import 'package:ceo_app/page/personal/index.dart';

final Map<String, Function> routes = {
  '/index': (context) => const Home(),
  '/login': (context) => const LoginPage(),
  '/publish': (context) => const PublishPage(),
  '/personal': (context) => const Personal(),
  '/circle': (context, {arguments}) => Circle(arguments: arguments),
};

var routers = (RouteSettings settings) {
  // 统一处理
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
  return null;
};
